package com.ldy.seal.web;

import java.util.HashMap;
import java.util.Map;
/**
 * response返回对象
 * @author lindeyi
 *
 */
public class Result {

	private int status;
	
	private Object data;
	
	public static Result success() {
		Result result = new Result();
		result.status = 0;
		return result;
	}
	public static Result success(Object data) {
		Result result = new Result();
		result.status = 0;
		result.data = data;
		return result;
	}
	public static Result failure(String msg) {
		Result result = new Result();
		result.status = -1;
		result.data = msg;
		return result;
	}
	public Result map(String key, Object val) {
		if (null == this.data) {
			this.data = new HashMap<>();
		}
		@SuppressWarnings("unchecked")
		Map<String, Object> map = (Map<String, Object>) this.data;
		map.put(key, val);
		return this;
	}
	
	
	/**
	 * @return the status
	 */
	public int getStatus() {
		return status;
	}
	/**
	 * @param status the status to set
	 */
	public void setStatus(int status) {
		this.status = status;
	}
	public Object getData() {
		return data;
	}
	public void setData(Object data) {
		this.data = data;
	}
	
	
}
